package com.ruoyi.system.service.impl;

import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author jiangwen
 */
@Service
public class KeepTalkingServiceImpl {

    public Object test1() {
        List<String> name = Arrays.asList("qazwsx", "edcrfv", "ujmiklop", "tgbyhn");
        List<String> list = Arrays.asList(
                "about", "after", "again", "below", "could",
                "every", "first", "found", "great", "house",
                "large", "learn", "never", "other", "place",
                "plant", "point", "right", "small", "sound",
                "spell", "still", "study", "their", "there",
                "these", "thing", "think", "three", "water",
                "where", "which", "world", "would", "write");
        return test1By(name, list, 0);
    }

    private List<String> test1By(List<String> name, List<String> list, int i){
        List<String> listReturn = new ArrayList<>();
        /* 循环题库 */
        for (String s : list) {
            /* 获取题库单词的第1个字母 */
            char item = s.charAt(i);
            String itemForName = name.get(i);
            boolean contains = itemForName.contains(String.valueOf(item));
            if(contains){
                listReturn.add(s);
            }
        }
        if(listReturn.size()>1){
            return test1By(name, listReturn, i+1);
        }else{
            return listReturn;
        }
    }

}
